package com.laint.hear.ui.fragment;


import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.laint.hear.R;
import com.laint.hear.adapter.BaseRecyclerViewViewHolder;
import com.laint.hear.ui.base.BaseRecyclerViewListFragment;

/**
 * Created by leiyingtao on 2016/10/14.
 */

public class NewsFragment extends BaseRecyclerViewListFragment<String> {

    @Override
    protected int getLayoutResID() {
        return R.layout.fragment_news;
    }


    @Override
    protected void setUpData() {
        for (int i = 0; i < 10; i++) {
            models.add("this is one test data :" + i);
        }
        super.setUpData();
    }

    @Override
    protected int getDataCount() {
        return models.size();
    }

    @Override
    protected RecyclerView.ViewHolder getViewHodler(ViewGroup parent, int viewType) {
        return new MyViewHolder(LayoutInflater.from(getActivity()).inflate(R.layout.item,parent,false));
    }

    class MyViewHolder extends BaseRecyclerViewViewHolder{

        TextView textView;
        public MyViewHolder(View itemView) {
            super(itemView);
            textView = (TextView)itemView.findViewById(R.id.text);
        }

        @Override
        public void initData(int position) {
            textView.setText(models.get(position));
        }
    }
}
